<script>
$(function() {
	$(".block_user_btn").button({
        icons: {
            primary: "ui-icon-cancel"
        },
        text: false
    });
    $(".recover_user_btn").button({
        icons: {
            primary: "ui-icon-arrowrefresh-1-s"
        },
        text: false
    });
});
</script>
<table cellspacing="0" class="classic_table">
<thead>
	<tr>
		<th>Nombre de Usuario</th>
		<th>Email</th>
		<th># Logins</th>
		<th>Último acceso</th>
		<th></th>
	</tr>
</thead>
<tbody>
	<?
	foreach($users as $user) {
	?>
	<tr>
		<td class="text_centered"><?= $user->username ?></td>
		<td class="text_centered"><?= $user->email ?></td>
		<td class="text_centered"><?= $user->logins ?></td>
		<td class="text_centered"><?= date('d/m/y H:i:s', $user->last_login) ?></td>
		<td class="text_centered">
			<div class="left">
			<? if(Auth::instance()->get_user()->id != $user->id) { ?>
				<? if($user->has('roles', ORM::factory('role', array('name' => 'login')))) { ?>
					<form action="<?= URL::site("admin/blockUser"); ?>">
						<input type="hidden" name="user" value="<?= $user->id ?>" />
						<button class="block_user_btn">Bloquear usuario</button>
					</form>
				<? }else{ ?>
					<form action="<?= URL::site("admin/recoverUser/"); ?>" >
						<input type="hidden" name="user" value="<?= $user->id ?>" />
						<button class="recover_user_btn">Recuperar usuario</button>
					</form>
				<?}?>
			<?}else{?>
				<div style="padding:8px;color:#ffffff;">_</div>
			<?}?>
			</div>
		</td>
	</tr>
	<?
	}
	?>
</tbody>
</table>
